package com.gxc.service.common.components.log.mq;

import com.gxc.service.common.components.log.model.GlobalAccessLog;
import com.gxc.service.common.model.constant.RabbitMqConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

import javax.annotation.Resource;

/**
 * 请求日志mq发送者.
 *
 * @author GongXincheng
 * @since 2019-11-09 00:51
 */
@Slf4j
public class LogMqSender {

    @Resource
    private RabbitTemplate rabbitTemplate;

    public void sendRequestInfoLogMessage(GlobalAccessLog logInfo) {
        try {
            rabbitTemplate.convertAndSend(RabbitMqConstant.EXCHANGE_NAME_LOG, RabbitMqConstant.QUEUE_NAME_LOG, logInfo);
            log.info("请求日志mq发送成功！");
        } catch (Exception e) {
            log.error("{} send request info log error! message:{}", this.getClass().getSimpleName(), e.getMessage());
        }
    }

}
